package com.example.test;

import org.openjdk.jol.info.ClassLayout;

import java.util.Random;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * @author shanchong
 * @date 2021/3/17
 **/
public class StringLoop {

    public static void main(String[] args) throws InterruptedException {
//        ExecutorService executorService = Executors.newFixedThreadPool(32);
//        Random random = new Random();
//        while (true) {
//            executorService.submit(()->{
//                StringBuffer stringBuffer = new StringBuffer();
//                stringBuffer.append(random.nextDouble());
//                stringBuffer.append(",");
//                stringBuffer.append(random.nextDouble());
//                stringBuffer.append(random.nextDouble());
//                stringBuffer.append(random.nextDouble());
//                stringBuffer.append(random.nextDouble());
//                stringBuffer.append(random.nextDouble());
//                stringBuffer.append(random.nextDouble());
//                String s =  stringBuffer.toString();
//                String intern = s.intern();
//                if (s == intern) {
//                    System.out.println("----");
//                }
//            });
//            Thread.sleep(100);
//        }
        String s = new String("1");
        String s2 = s.intern();
        System.out.println(s == s2); //false
        String s3 = "1";
        System.out.println(s3 == s2); //true

    }

}
